package com.valveinspectionsys.util;

import java.util.ArrayList;
import java.util.Collection;

public class NotRepeatedList <E> extends ArrayList<E>{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public NotRepeatedList() {
        super();
    }
    
    public NotRepeatedList(Collection<? extends E> c) {
        addAll(c);
    }
   
    public NotRepeatedList(int initialCapacity) {
        super(initialCapacity);
    }
    
    @Override
    public boolean add(E o) {
        if (!contains(o)) {
            return super.add(o);
        }
        return false;
    };

    @Override
    public void add(int index, E element) {
        if (!contains(element)) {
            super.add(index, element);
        }
    };

    @Override
    public boolean addAll(Collection<? extends E> c) {
        int number = size();
        ensureCapacity(size() + c.size());
        for (E e : c) {
            add(e);
        }
        return number == size() ? false : true;
    }
    @Override
    public boolean addAll(int index, Collection<? extends E> c) {
        int number = size();
        ensureCapacity(size() + c.size());
        int i = index;
        for (E e : c) {
            if (!contains(e)) {
                super.add(i, e);
                i++;
            }
        }
        return number == size() ? false : true;
    }

    
 



    @Override
    public boolean removeAll(Collection<?> collection) {
	// TODO Auto-generated method stub
	return super.removeAll(collection);
    }
     
    
}
